import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/components/login.vue'
import Home from '@/components/home.vue'
import CreatNews from '@/components/creat_news.vue'
import ReivseNews from '@/components/revise_news.vue'
import CreatRecruitment from '@/components/creat_recruitment.vue'
import ReivseRecruitment from '@/components/revise_recruitment.vue'
import Information from '@/components/information.vue'
import NewsList from '@/components/newsList.vue'
import RecruitmentList from '@/components/recruitmentList.vue'
import RecycleBinNews from '@/components/recycleBinNews.vue'
import RecycleBinRecruitment from '@/components/recycleBinRecruitment.vue'
import Project_introduction from '@/components/project_introduction.vue'
import RecycleBinProject from '@/components/recycleBinProject.vue'

Vue.use(Router)

 const router = new Router({
  routes: [
    {path:'/',redirect:'/login'},
    {path:'/login',component:Login},
    {
    path:'/home',
    component:Home,
    redirect: '/creat_recruitment',
    children:[{name:'newsList',path:'/newsList',component:NewsList},
              {name:'recruitmentList',path:'/recruitmentList',component:RecruitmentList},
              {name:'information',path:'/information',component:Information},
              {name:'creat_news',path:'/creat_news',component:CreatNews},
              {name:'revise_news',path:'/revise_news',component:ReivseNews},
              {name:'creat_recruitment',path:'/creat_recruitment',component:CreatRecruitment},
              {name:'reivse_recruitment',path:'/reivse_recruitment',component:ReivseRecruitment},
              {name:'recycle_binNews',path:'/recycle_binNews',component:RecycleBinNews},
              {name:'recycle_binRecruitment',path:'/recycle_binRecruitment',component:RecycleBinRecruitment},
              {name:'project_introduction',path:'/project_introduction',component:Project_introduction},
              {name:'recycleBinProject',path:'/recycleBinProject',component:RecycleBinProject}

    ]}
  ]
})

// 挂载导航守卫
// router.beforeEach((to, from, next)=> {
//   // to 将要访问的路径
//   // from 代表从哪个路径跳转而来
//   // next 是一个函数，表示放行
//   if(to.path === '/login') return next()
//   // 获取state
//   const code = window.sessionStorage.getItem('code')
//  if(!code) return next('/login')
// })

export default router
